---
sidebar_position: 3
title: isHotkeyPressed
---

# isHotkeyPressed API

Function signature:

```ts
function isHotkeyPressed(key: string | string[], splitKey: string = ','): boolean
```

This function allows us to check if a specific key is pressed by the user.

```jsx
const isHotkeyPressed = useIsHotkeyPressed();

const onClick = () => isHotkeyPressed('shift') ? setCount(count - 1) : setCount(count + 1);
```

***

## Arguments

### key

```ts
key: string | string[]
```

The key we want to listen to. This can be a string (like `'a'`, `'shift+a'`) or an array of strings (like `['a', 'shift+a']`).

### splitKey

```ts
key: string = ','
```

We can combine to check for multiple keys in one string by separating them with a comma (`,`). We can change
this by passing a different key.

## Return value

### boolean

The function returns `true` if the key or keystroke is currently pressed down, otherwise it will return `false`.
